package com.mew.lobby.handler.gold;

import com.mew.common.exception.ResponseCode;
import com.mew.common.rest.LongMessage;
import com.mew.common.rest.bo.MewSession;
import com.mew.common.rest.user.UserMoneyResponseMessage;
import com.mew.lobby.annotation.LobbyHandler;
import com.mew.lobby.net.LobbyHandlerMapCmdType;
import com.mew.lobby.net.MewHandler;
import com.mew.lobby.provide.GoldFeignService;
import com.zebra.remoting.protocol.ZebraCommand;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ResponseBody;

@Service
@Slf4j
@LobbyHandler(LobbyHandlerMapCmdType.JeweAll2Gold)
public class JeweAll2GoldHandler implements MewHandler<LongMessage> {

    @Autowired
    private GoldFeignService goldFeignService;
    @Override
    public void handle(ZebraCommand<LongMessage> zebraCommand, MewSession session) {
        long num = zebraCommand.getRequest().getL();
        if(num <= 0){}{
            zebraCommand.sendFailureCode(ResponseCode.ParamInvalid.code());
        }
        UserMoneyResponseMessage message = goldFeignService.gold2(session.uid, num);
        zebraCommand.sendMessage(message);
    }
}
